<?php
namespace app\ice\model;
use think\Db;
use think\Model;
use think\Cache;

class Area extends Model
{
    protected $table = 'ig_area';
    // 查看首页详情
    public function getListData($level)
    {   
        // $cache = Cache::get('licensePlate');
        // dump($cache);
        // exit;
        // if($cache){
        //     return $cache;
        // }
        $where = [];
        if($level){
            $where['level'] = $level;
        }else{
            $where['level'] = ['gt',$level];
        }
        $data = $this
            ->where('status',1)
            ->where($where)
            // ->order('sort desc')
            ->select();
            if(!$level){
                $data = getTreeDataPhp($data);
            }
        // Cache::set('licensePlate',$data);
        return $data;
    }

    public function getName($id){
        return $this->where('id',$id)->value('name');
    }
    // 查看首页详情
    public function getList($data,$page,$orll_page)
    {
        $list['row'] = $this->table('kc_discount')
            ->where('d_type',$data['type'])
            ->page($page,$orll_page)
            ->select();
        $total = $this->table('kc_discount')
            ->where('d_type',$data['type'])
            ->count();
        $list['count'] = ceil($total/$orll_page);
        $list['page'] = $page;
        if(count($list['row']) < 1 ){
            return false;
        }
        return $list;
    }
}